package pers.wensheng.patterns.behavioral_pattern.command_pattern.entity;

import lombok.AllArgsConstructor;

import java.util.Map;

/**
 * 具体命令类
 */
@AllArgsConstructor
public class OrderCommand implements Command {

    /**
     * 持有接收者对象
     */
    private SeniorChef receiver;

    /**
     * 持有订单对象
     */
    private Order order;


    /**
     * 执行命令
     */
    @Override
    public void execute() {

        System.out.println(order.getDiningTable()+"桌的订单：");

        Map<String, Integer> map = order.getFoodDir();
        for (String foodName : map.keySet()) {
            //让厨师做该餐品
            receiver.makeFood(foodName,map.get(foodName));
        }

        System.out.println(order.getDiningTable()+"桌的饭准备完毕");
    }
}
